using Bases;
using Mgrs;
using Modules.Game;
using UnityEditor;
using UnityEngine.UI;

namespace Modules.GameOver
{
    public class GameOverPanel : MonoBehaviourSimplify
    {
        public Button btnRestart;
        public Button btnExit;

        public Text scoreText;
        public Text maxScoreText;

        private void Awake()
        {
            btnRestart.onClick.AddListener(OnBtnRestart);
            btnExit.onClick.AddListener(OnBtnExit);

            scoreText.text = "Score: " + GameModel.Instance.Score;
            maxScoreText.text = "MaxScore: " + GameModel.Instance.MaxScore;
        }

        protected override void OnBeforeDestroy()
        {
        }

        private void OnBtnRestart()
        {
            GUIManager.UnLoadPanel(nameof(GameOverPanel));

            GameModule.Instance.GameRestart();
        }

        private void OnBtnExit()
        {
            GUIManager.UnLoadPanel(nameof(GameOverPanel));

#if UNITY_EDITOR
            EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }
    }
}